package com.hdu.hot100.arr;

public class lc189 {
    class Solution {
        public void rotate(int[] nums, int k) {
            int len = nums.length;
            k %= len;
            swap(nums, 0, len - 1);
            swap(nums, 0, k - 1);
            swap(nums, k, len - 1);
        }

        void swap(int[] nums, int l, int r)
        {
            while (l < r)
            {
                int temp = nums[l];
                nums[l] = nums[r];
                nums[r] = temp;
                l++;
                r--;
            }
        }
    }
}
